<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core">
    <h:head>
        <title>Facelet Title</title>
    </h:head>
    <h:body>
        <ui:composition template="/templates/default.xhtml">
            <ui:define name="content">
                <h:form>

                    <h:commandButton value="#{locale.buttonNewUser}" action="#{newUser.addNewUser}" />
                    <h:outputText value="       #{locale.roleLegend}" />
                    <p/>
                    <h:dataTable value="#{userList.users}" var="u" >
                        <h:column>
                            <f:facet name="header">
                                #{locale.dtHeaderFirstName}
                            </f:facet>
                            <h:inputText value="#{u.firstName}" size="10" rendered="#{u.editable}" />
                            <h:outputText value="#{u.firstName}" rendered="#{not u.editable}"/>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                #{locale.dtHeaderLastName}
                            </f:facet>
                            <h:inputText value="#{u.lastName}" size="10" rendered="#{u.editable}" />
                            <h:outputText value="#{u.lastName}" rendered="#{not u.editable}"/>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                #{locale.dtHeaderEmail}
                            </f:facet>
                            <h:inputText value="#{u.email}" rendered="#{u.editable}" />
                            <h:outputText value="#{u.email}" rendered="#{not u.editable}"/>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                #{locale.dtHeaderUserName}
                            </f:facet>
                            <h:inputText value="#{u.userName}" size="10" rendered="#{u.editable}" />
                            <h:outputText value="#{u.userName}" rendered="#{not u.editable}"/>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                #{locale.dtHeaderDateRegistered}
                            </f:facet>
                            <h:outputText value="#{u.dateRegistered}" />
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                #{locale.dtHeaderDateLastLoggedIn}
                            </f:facet>
                            <h:outputText value="#{u.dateLastLoggedIn}" />
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                #{locale.dtHeaderRole1}
                            </f:facet>
                            <h:outputText value="#{u.sysadmin}" />
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                #{locale.dtHeaderRole2}
                            </f:facet>
                            <h:outputText value="#{u.adminresource}" />
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                #{locale.dtHeaderRole3}
                            </f:facet>
                            <h:outputText value="#{u.teacher}" />
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                #{locale.dtHeaderRole4}
                            </f:facet>
                            <h:outputText value="#{u.studyadmin}" />
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                #{locale.dtHeaderEdit}
                            </f:facet>
                            <h:commandButton value="#{locale.buttonEdit}" action="#{u.setEditable(true)}" rendered="#{not u.editable}" />
                            <h:commandButton value="#{locale.buttonSave}" action="#{userList.executeChanges}" rendered="#{u.editable}" />
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                #{locale.dtHeaderDelete}
                            </f:facet>
                            <h:commandButton value="#{locale.buttonDelete}" action="#{userList.setDeleteFlagAndNavigate(u)}" />
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                #{locale.dtHeaderNewPassword}
                            </f:facet>
                            <h:commandButton value="#{locale.buttonNewPassword}" action="#{userList.setNewPasswordFlagAndNavigate(u)}" />
                        </h:column>
                    </h:dataTable>
                 </h:form>
            </ui:define>
        </ui:composition>
    </h:body>
</html>

